<div class="links index">
	<h2><?php echo __('Links');?></h2>
	<table cellpadding="0" cellspacing="0">
	<tr>
			<th><?php echo $this->Paginator->sort('id');?></th>
			<th><?php echo $this->Paginator->sort('project_id');?></th>
			<th><?php echo $this->Paginator->sort('back_links');?></th>
			<th><?php echo $this->Paginator->sort('target_links');?></th>
			<th><?php echo $this->Paginator->sort('anchor_text');?></th>
			<th><?php echo $this->Paginator->sort('display_time');?></th>
			<th><?php echo $this->Paginator->sort('status');?></th>
			<th class="actions"><?php echo $this->Html->link(__('New Link'), array('action' => 'add')); ?></th>
	</tr>
	<?php
	foreach ($links as $link): ?>
	<tr>
		<td><?php echo h($link['Link']['id']); ?>&nbsp;</td>
		<td><?php if(isset($link['Project']) && count($link['Project']) != 0 ){ $i=0; foreach ($link['Project'] as $project) { echo (($i != 0)?'<br/>':'').$this->Html->link($project['domain'],array('controller'=>'projects','action'=>'view',$project['id'])); $i++; } } ?>&nbsp;</td>
		<td><?php if (strpbrk($link['Link']['back_links'], ';') == FALSE) {
					echo $this->Html->link($link['Link']['back_links'],'http://'.$link['Link']['back_links']);
				}else{ 
					$links = explode(';',$link['Link']['back_links']);
					$i = 0;
					foreach ($links as $lik) {
						echo ($i != 0) ? '<br/>':'';
						echo $this->Html->link($lik,'http://'.$lik);
						$i++;
					}
				}
		?>&nbsp;</td>
		<td><?php echo h($link['Link']['target_links']); ?>&nbsp;</td>
		<td><?php echo h($link['Link']['anchor_text']); ?>&nbsp;</td>
		<td><?php echo h($link['Link']['display_time']); ?>&nbsp;</td>
		<td><?php echo h($link['Link']['status']); ?>&nbsp;</td>
		<td class="actions">
			<?php echo $this->Html->link(__('View'), array('action' => 'view', $link['Link']['id'])); ?>
			<?php echo $this->Html->link(__('Edit'), array('action' => 'edit', $link['Link']['id'])); ?>
			<?php echo $this->Form->postLink(__('Delete'), array('action' => 'delete', $link['Link']['id']), null, __('Are you sure you want to delete # %s?', $link['Link']['id'])); ?>
		</td>
	</tr>
<?php endforeach; ?>
	</table>
	<p>
	<?php
	echo $this->Paginator->counter(array(
	'format' => __('Page {:page} of {:pages}, showing {:current} records out of {:count} total, starting on record {:start}, ending on {:end}')
	));
	?>	</p>

	<div class="paging">
	<?php
		echo $this->Paginator->prev('< ' . __('previous'), array(), null, array('class' => 'prev disabled'));
		echo $this->Paginator->numbers(array('separator' => ''));
		echo $this->Paginator->next(__('next') . ' >', array(), null, array('class' => 'next disabled'));
	?>
	</div>
</div>

<div class="actions">	
	<?php echo $this->element('/menu/main')?>
	<?php echo $this->element('/menu/settings')?>
</div>

